﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Rpc.TouchRpc;
using TouchSocket.Sockets;

namespace Updater.Core
{
    /// <summary>
    /// 服务器事件接口
    /// </summary>
    public interface IServerEvent
    {
        /// <summary>
        /// 即将接收流数据，用户需要在此事件中对e.Bucket初始化。
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void StreamTransfering(TcpTouchRpcSocketClient client, StreamOperationEventArgs e);

        /// <summary>
        /// 流数据处理，用户需要在此事件中对e.Bucket手动释放。
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void StreamTransfered(TcpTouchRpcSocketClient client, StreamStatusEventArgs e);

        /// <summary>
        /// 收到数据
        /// </summary>
        /// <param name="client"></param>
        /// <param name="protocol"></param>
        /// <param name="byteBlock"></param>
        void Received(TcpTouchRpcSocketClient client, short protocol, TouchSocket.Core.ByteManager.ByteBlock byteBlock);

        /// <summary>
        /// 当客户端ID被修改时触发。
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void IDChanged(TcpTouchRpcSocketClient client, TouchSocketEventArgs e);

        /// <summary>
        /// 表示即将握手
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void Handshaking(TcpTouchRpcSocketClient client, VerifyOptionEventArgs e);

        /// <summary>
        /// 在完成握手连接时
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void Handshaked(TcpTouchRpcSocketClient client, VerifyOptionEventArgs e);

        /// <summary>
        /// 文件传输开始之前
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void FileTransfering(TcpTouchRpcSocketClient client, FileOperationEventArgs e);

        /// <summary>
        ///  当文件传输结束之后。并不意味着完成传输，请通过TouchSocket.Rpc.TouchRpc.FileTransferStatusEventArgs.Result属性值进行判断。
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void FileTransfered(TcpTouchRpcSocketClient client, FileTransferStatusEventArgs e);

        /// <summary>
        /// 有用户断开连接
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void Disconnected(TcpTouchRpcSocketClient client, ClientDisconnectedEventArgs e);

        /// <summary>
        /// 有用户连接的时候
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void Connecting(TcpTouchRpcSocketClient client, ClientOperationEventArgs e);
        /// <summary>
        /// 用户连接完成
        /// </summary>
        /// <param name="client"></param>
        /// <param name="e"></param>
        void Connected(TcpTouchRpcSocketClient client, TouchSocketEventArgs e);
     
    }
}
